<?php
date_default_timezone_set("Asia/Krasnoyarsk");
//Set header charset
header("Content-Type: text/html; charset=UTF-8");
// Define đường dẫn tới thư mục application
defined('APPLICATION_PATH') || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/application'));

//Define đường dẫn tới area nếu bạn sử dụng area
defined('AREA_PATH') || define('AREA_PATH', realpath(dirname(__FILE__) . '/areas'));

set_include_path(realpath(dirname(__FILE__)).PATH_SEPARATOR."library".PATH_SEPARATOR."application/models");

require_once 'library/XPHP/Loader.php';
XPHP_Loader::registerAutoload();

//Config
require_once 'config.php';
XPHP_Registry::set("config", XPHP_Array::toObject($config));
//DB Factory
$dbinfo = $config['database'];
$DBFactory = new XPHP_DB_Factory($dbinfo['server'], $dbinfo['dbname'], $dbinfo['username'], $dbinfo['password']);
$DBFactory->setDefaultDBFactory();

//Dispatch application
$controller = new XPHP_Controller_Front();
$controller->dispatch();